<template>
  <div>
    <div class="address-list" v-loading="loading">
      <div class="address-item" v-for="(item, index) in list" :key="index">
        <div class="item-on" :class="{on:item.on && select}" @click="switchAddress(item)">
          <div class="address-info">
            <div class="name">
              {{ item.name }}
              <span v-if="item.defaults">{{ $t('address.default') }}</span>
            </div>
            <div class="cellphone">{{ item.cellphone }}</div>
            <div class="address-con">{{ item.location ? item.location + '' : '' }}/{{ item.house ? '' + item.house : '' }}</div>
            <div class="address-con">{{ item.address }}</div>
            <div class="address-action">
              <el-link style="margin-left: 10px;" v-if="!select" :underline="false" @click="defaultAddress(item)">{{ $t('address.set_default') }}</el-link>
              <el-link style="margin-left: 10px;" :underline="false" @click="updateAddress(item)">{{ $t('common.amend') }}</el-link>
              <el-link v-if="!select" type="danger" :underline="false" @click="deleteAddress(item)">{{ $t('common.delete') }}</el-link>
            </div>
          </div>
        </div>
      </div>
      <div class="address-item" @click="updateAddress">
        <div class="item">
          <div class="add-desc">
            <div><i class="el-icon-circle-plus"></i></div>
            <div>{{ $t('address.add_new') }}</div>
          </div>
        </div>
      </div>
    </div>
    <el-dialog :title="dialogTitle" :visible.sync="centerDialogVisible" :close-on-click-modal="false" width="600px;overflow-y: auto;">
      <el-form class="ruleForm" :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px">
        <el-form-item :label="$t('address.name')" prop="name">
          <el-input :placeholder="$t('hint.error.import', { attribute: '받는 주소' })" v-model="ruleForm.name" clearable maxlength="20"></el-input>
        </el-form-item>
        <el-form-item :label="$t('find_password.cellphone')" prop="cellphone">
          <el-input :placeholder="$t('hint.error.import', { attribute: $t('find_password.cellphone') })" v-model="ruleForm.cellphone" clearable maxlength="20"></el-input>
        </el-form-item>
        <!-- 通关码 -->
        <el-form-item label="통관번호 입력" prop="address">
          <el-input :placeholder="$t('hint.error.import', { attribute: '통관번호 입력' })" v-model="ruleForm.address" clearable maxlength="80"></el-input>
          <!-- <el-input :placeholder="$t('hint.error.import', { attribute: '통관번호 입력' })" v-model="ruleForm.longitude" clearable maxlength="80"></el-input> -->
          <a href="https://unipass.customs.go.kr/csp/persIndex.do" target="_blank" rel="noopener noreferrer">통관번호 없음 ? <b style="color: red;font-weight: normal;">가입 바로 갑니다</b> </a>
        </el-form-item>
        <el-form-item :label="$t('address.location')" prop="location">
          <!-- <div v-if="ruleForm.longitude">{{ruleForm.location}}({{ruleForm.address}})</div>
          <div v-else>{{ $t('address.location.tip') }}</div>
          <iframe v-if="ruleForm.longitude" class="iframe" height="500" frameborder=0 :src="`${src}&coord=${ruleForm.latitude},${ruleForm.longitude}`"></iframe>
          <iframe v-else class="iframe" height="500" frameborder=0 :src="src"></iframe> -->
          <el-input :placeholder="$t('hint.error.import', { attribute: $t('address.location.tip') })" v-model="ruleForm.location" clearable maxlength="100"></el-input>
        </el-form-item>
        <el-form-item label="상세주소" prop="house">
          <el-input :placeholder="$t('hint.error.import', { attribute: '상세주소' })" v-model="ruleForm.house" clearable maxlength="80"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" @click="centerDialogVisible = false">{{ $t('common.cancel') }}</el-button>
        <el-button :loading="buttonLoading" type="danger" @click="submitForm('ruleForm')">{{ $t('common.confirm') }}</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<style lang='scss' scoped>
@import './scss/list';
</style>

<script>
import js from './js/list'
export default js
</script>
